
import { Links } from '/imports/api/links/links.js';
import { Areas } from '/imports/api/areas/areas.js';
import { Cates } from '/imports/api/cates/cates.js';

export function createLink(name, url, area, cate, weight){
  if (Links.find({name: name}).count() == 0) {
        Links.insert({
          name,
          url,
          area,
          cate,
          weight,
          createdAt: new Date(),
        });

        if (Areas.find({name: area}).count() == 0) {
          Areas.insert({
            name: area,
            createdAt: new Date(),
          });
        }
        if (Cates.find({name: cate}).count() == 0) {
          Cates.insert({
            name: cate,
            area: area,
            createdAt: new Date(),
          });
        }



  }else{

  }
}
